#include "garmin_tables.h"
#include <ctype.h>
-static FILE *file_in;
-static FILE *file_out;
+static gbfile *file_in, *file_out;
static short_handle mkshort_handle;
static short_handle mkshort_handle2; /* for track and route names */
static char *deficon = NULL;
static void
rd_init(const char *fname)
{
- file_in = xfopen(fname, "rb", MYNAME);
+ file_in = gbfopen(fname, "rb", MYNAME);
}
static void
rd_deinit(void)
{
- fclose(file_in);
+ gbfclose(file_in);
}
static void
wr_init(const char *fname)
{
- file_out = xfopen(fname, "w", MYNAME);
+ file_out = gbfopen(fname, "w", MYNAME);
mkshort_handle = mkshort_new_handle();
mkshort_handle2 = mkshort_new_handle();
}
static void
wr_deinit(void)
{
- fclose(file_out);
+ gbfclose(file_out);
mkshort_del_handle(&mkshort_handle);
mkshort_del_handle(&mkshort_handle2);
}
route_head *route = NULL;
int n;
char lathemi, lonhemi;
- textfile_t *tin;
read_as_degrees = 0;
- tin = textfile_init(file_in);
- while ((buff = textfile_read(tin)))
+ while ((buff = gbfgetstr(file_in)))
{
char *ibuf = lrtrim(buff);
char *cp;
;
}
}
- textfile_done(tin);
}
static void
}
- fprintf(file_out, "W %-6.6s %c%08.5f %c%011.5f %s %5d %-40.40s %5e %d\n",
+ gbfprintf(file_out, "W %-6.6s %c%08.5f %c%011.5f %s %5d %-40.40s %5e %d\n",
global_opts.synthesize_shortnames ?
mkshort_from_wpt(mkshort_handle, wpt) :
wpt->shortname,
* so provide option to supppress these.
*/
if (!cartoexploreur) {
- fprintf(file_out, "\n\nH TN %s\n", name);
+ gbfprintf(file_out, "\n\nH TN %s\n", name);
}
xfree(name);
- fprintf(file_out, "H LATITUDE LONGITUDE DATE TIME ALT ;track\n");
+ gbfprintf(file_out, "H LATITUDE LONGITUDE DATE TIME ALT ;track\n");
}
static void
/* see pcx_track_hdr */
if (!cartoexploreur) {
- fprintf(file_out, "\n\nR %s\n", name);
+ gbfprintf(file_out, "\n\nR %s\n", name);
}
- fprintf(file_out, "\n"
+ gbfprintf(file_out, "\n"
"H IDNT LATITUDE LONGITUDE DATE TIME ALT DESCRIPTION PROXIMITY SYMBOL ;waypts\n");
}
for (tp = tbuf; *tp; tp++) {
*tp = toupper(*tp);
}
- fprintf(file_out, "T %c%08.5f %c%011.5f %s %.f\n",
+ gbfprintf(file_out, "T %c%08.5f %c%011.5f %s %.f\n",
lat < 0.0 ? 'S' : 'N',
fabs(lat),
lon < 0.0 ? 'W' : 'E',
static void
data_write(void)
{
-fprintf(file_out,
+gbfprintf(file_out,
"H SOFTWARE NAME & VERSION\n"
"I PCX5 2.09\n"
"\n"
if (global_opts.objective == wptdata)
{
- fprintf(file_out,
+ gbfprintf(file_out,
"\n"
"H IDNT LATITUDE LONGITUDE DATE TIME ALT DESCRIPTION PROXIMITY SYMBOL ;waypts\n");
#include "defs.h"
#include "csv_util.h"
-static FILE *file_in;
-static FILE *file_out;
+static gbfile *file_in, *file_out;
static short_handle mkshort_handle;
static short_handle mkshort_whandle;
static void
rd_init(const char *fname)
{
- file_in = xfopen(fname, "rb", MYNAME);
+ file_in = gbfopen(fname, "rb", MYNAME);
mkshort_handle = mkshort_new_handle();
}
static void
rd_deinit(void)
{
- fclose(file_in);
+ gbfclose(file_in);
mkshort_del_handle(&mkshort_handle);
}
static void
wr_init(const char *fname)
{
- file_out = xfopen(fname, "w", MYNAME);
+ file_out = gbfopen(fname, "w", MYNAME);
thresh_days = strtod(oldthresh, NULL);
}
static void
wr_deinit(void)
{
- fclose(file_out);
+ gbfclose(file_out);
}
static void
char icon[100];
char *ibuf;
waypoint *wpt_tmp;
- textfile_t *tin;
-
- tin = textfile_init(file_in);
- while ((ibuf = textfile_read(tin))) {
+ while ((ibuf = gbfgetstr(file_in))) {
if( sscanf(ibuf, "%lf,%lf:%100[^:]:%100[^\n]",
&lon, &lat, icon, desc)) {
wpt_tmp = waypt_new();
waypt_add(wpt_tmp);
}
}
- textfile_done(tin);
}
static void
if (lon < minlon) minlon = lon;
}
- fprintf(file_out, "%f,%f:%s", lon, lat, pin);
+ gbfprintf(file_out, "%f,%f:%s", lon, lat, pin);
if (!nolabels) {
char *temp = NULL;
char *desc = csv_stringclean(wpt->description, ":");
temp = desc;
desc = mkshort(mkshort_whandle, desc);
}
- fprintf(file_out, ":%s", desc);
+ gbfprintf(file_out, ":%s", desc);
if (temp != NULL) desc = temp;
xfree(desc);
}
- fprintf(file_out, "\n");
+ gbfprintf(file_out, "\n");
}
#if CLICKMAP
x+=10;
y+=10;
- fprintf(linkf, "<area shape=\"circle\" coords=\"%d,%d,7\" href=\"%s\" alt=\"%s\"\n", x, y, wpt->url, wpt->description);
+ gbfprintf(linkf, "<area shape=\"circle\" coords=\"%d,%d,7\" href=\"%s\" alt=\"%s\"\n", x, y, wpt->url, wpt->description);
}
#endif /* CLICKMAP */
setshort_length(mkshort_whandle, short_length);
- fprintf(file_out, "#tms-marker\n");
+ gbfprintf(file_out, "#tms-marker\n");
waypt_disp_all(tiger_disp);
if (genurl) {
- FILE *urlf;
+ gbfile *urlf;
- urlf = xfopen(genurl, "w", MYNAME);
+ urlf = gbfopen(genurl, "w", MYNAME);
latsz = fabs(maxlat - minlat);
lonsz = fabs(maxlon - minlon);
* Center the map along X and Y axis the midpoint of
* our min and max coords each way.
*/
- fprintf(urlf, "lat=%f&lon=%f&ht=%f&wid=%f",
+ gbfprintf(urlf, "lat=%f&lon=%f&ht=%f&wid=%f",
minlat + (latsz/2.0),
minlon + (lonsz/2.0),
dscale(latsz),
dscale(lonsz));
- fprintf(urlf, "&iwd=%s&iht=%s", xpixels, ypixels);
- fclose(urlf);
+ gbfprintf(urlf, "&iwd=%s&iht=%s", xpixels, ypixels);
+ gbfclose(urlf);
#if CLICKMAP
if (clickmap) {
- linkf = xfopen(clickmap, "w", MY NAME);
- fprintf(linkf, "<map name=\"map\">\n");
+ linkf = gbfopen(clickmap, "w", MY NAME);
+ gbfprintf(linkf, "<map name=\"map\">\n");
waypt_disp_all(map_plot);
- fprintf(linkf, "</map>\n");
- fclose(linkf);
+ gbfprintf(linkf, "</map>\n");
+ gbfclose(linkf);
linkf = NULL;
}
#endif